package org.batatasframework.chart.columns;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ColumnAxisDate extends AbstractFormatableColumn<Date> implements ChartColumnAxis{

	private final int indexOf;

	public ColumnAxisDate(String name, int indexOf) {
		super(name);
		this.indexOf = indexOf;
	}

	public ColumnAxisDate(String name, int indexOf, String pattern) {
		super(name);
		this.indexOf = indexOf;
		this.format = new SimpleDateFormat(pattern);
	}

	@Override
	protected Date internalParseValue(Object[] row) {
		return(indexOf < row.length) ? (Date)row[indexOf] : null;
	}
}
